/*
 * 10.5.cpp 1458_poj
 *
 *  Created on: 2012-5-16
 *      Author: jawinton
 */


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 201

char s1[MAX], s2[MAX];
int common[MAX][MAX];

int comLen(int i, int j) {
	if (i==0 || j==0)
		common[i][j] = 0;
	if (common[i][j] != -1) return common[i][j];
	if (s1[i-1] == s2[j-1]) {
		common[i][j] = comLen(i-1, j-1)+1;
	} else common[i][j] = max(comLen(i-1, j), comLen(i, j-1));
	return common[i][j];
}

int main (void) {
	while (scanf("%s %s", s1, s2) > 0) {
		int len1 = strlen(s1), len2 = strlen(s2);
		for (int i=0; i<=len1; i++) {
			for (int j=0; j<=len2; j++) {
				common[i][j] = -1;
			}
		}
		printf("%d\n", comLen(len1, len2));
	}
	return 0;
}
